export default {
  install: function(Vue) {
    Vue.prototype.timestampToTime = function(time, cFormat) {
      if (arguments.length === 0) {
        return null;
      }
      const format = cFormat || "{y}-{m}-{d} {h}:{i}:{s}";
      let date;
      if (typeof time === "object") {
        date = time;
      } else {
        if (("" + time).length === 10) time = parseInt(time);
        date = new Date(time);
      }
      const formatObj = {
        y: date.getFullYear(),
        m: date.getMonth() + 1,
        d: date.getDate(),
        h: date.getHours(),
        i: date.getMinutes(),
        s: date.getSeconds(),
        a: date.getDay()
      };
      const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
        let value = formatObj[key];
        if (key === "a") {
          return ["一", "二", "三", "四", "五", "六", "日"][value - 1];
        }
        if (result.length > 0 && value < 10) {
          value = "0" + value;
        }
        return value || 0;
      });
      return time_str;
    };
    Vue.prototype.statusEstimation = function(status) {
      switch (parseInt(status)) {
        case 1:
          return "审核中";
        case 2:
          return "审核通过";
        case 3:
          return "未通过";
        case 4:
          return "禁用";
        default:
          return status;
      }
    };
    Vue.prototype.statusEsSecond = function(status) {
      switch (parseInt(status)) {
        case 0:
          return "审核中";
        case 1:
          return "审核通过";
        case 2:
          return "未通过";
        case 3:
          return "禁用";
        default:
          return status;
      }
    };
    Vue.prototype.disableEs = function(status) {
      switch (parseInt(status)) {
        case 1:
          return "正常";
        case 2:
          return "禁用";
        default:
          return status;
      }
    };
    Vue.prototype.disableEsSecond = function(status) {
      switch (parseInt(status)) {
        case 1:
          return "正常";
        case 3:
          return "禁用";
        default:
          return status;
      }
    };
    Vue.prototype.merchantStatusEs = function(status) {
      switch (parseInt(status)) {
        case 0:
          return "经营中";
        case 1:
          return "注册中";
        case 2:
          return "审核不通过";
        case 3:
          return "停业";
        case 4:
          return "审核中";
        default:
          return status;
      }
    };
    Vue.prototype.vidioStatusEs = function(status) {
      switch (parseInt(status)) {
        case 1:
          return "视频审核中";
        case 2:
          return "规则待添加";
        case 3:
          return "规则待审核";
        case 4:
          return "发布中";
        case 5:
          return "发布中[规则审核]";
        case 6:
          return "发布结束";
        default:
          return status;
      }
    };
    Vue.prototype.playEs = function(status) {
      switch (parseInt(status)) {
        case 1:
          return "待播放";
        case 2:
          return "播放中";
        case 3:
          return "已结束";
        default:
          return status;
      }
    };
    Vue.prototype.buyerTypeEs = function(type) {
      switch (parseInt(type)) {
        case 1:
          return "运营中心";
        case 2:
          return "广告主";
        case 3:
          return "商家";
        default:
          return type;
      }
    };
    Vue.prototype.operationsTypeEs = function(type) {
      switch (parseInt(type)) {
        case 0:
          return "平台总部";
        case 1:
          return "省级运营中心";
        case 2:
          return "市级运营中心";
        case 3:
          return "区级运营中心";
        default:
          return type;
      }
    };
    Vue.prototype.areaTypeEs = function(type) {
      switch (parseInt(type)) {
        case 0:
          return "国家";
        case 1:
          return "省份";
        case 2:
          return "城市";
        case 3:
          return "区县";
        default:
          return type;
      }
    };
    Vue.prototype.leaveEs = function(status) {
      switch (parseInt(status)) {
        case 0:
          return "在岗";
        case 1:
          return "离职";
        default:
          return status;
      }
    };
    Vue.prototype.sexEs = function(sex) {
      switch (parseInt(sex)) {
        case 1:
          return "男";
        case 2:
          return "女";
        default:
          return sex;
      }
    };
    Vue.prototype.whetherEs = function(status) {
      switch (parseInt(status)) {
        case 0:
          return "否";
        case 1:
          return "是";
        default:
          return status;
      }
    };
    Vue.prototype.whetherEsSecond = function(status) {
      switch (parseInt(status)) {
        case 1:
          return "是";
        case 2:
          return "否";
        default:
          return status;
      }
    };
    Vue.prototype.shelfEs = function(status) {
      switch (parseInt(status)) {
        case 1:
          return "上架";
        case 2:
          return "下架";
        default:
          return status;
      }
    };
    Vue.prototype.switchEs = function(status) {
      switch (parseInt(status)) {
        case 0:
          return "开启";
        case 1:
          return "关闭";
        default:
          return status;
      }
    };
    Vue.prototype.switchEsSecond = function(status) {
      switch (parseInt(status)) {
        case 1:
          return "开机";
        case 2:
          return "关机";
        default:
          return status;
      }
    };
    Vue.prototype.typeEstimation = function(type) {
      switch (parseInt(type)) {
        case 1:
          return "开机";
        case 2:
          return "关机";
        case 3:
          return "网络异常";
        case 4:
          return "app启动";
        case 5:
          return "app关闭";
        case 6:
          return "结束播放";
        case 7:
          return "开始播放";
        case 8:
          return "播放异常";
        default:
          return type;
      }
    };
    Vue.prototype.paymentMethodEs = function(type) {
      switch (parseInt(type)) {
        case 1:
          return "微信";
        case 2:
          return "支付宝";
        case 3:
          return "转账";
        case 4:
          return "现金";
        case 5:
          return "易物";
        default:
          return type;
      }
    };
    Vue.prototype.rechargeEs = function(status) {
      switch (parseInt(status)) {
        case 1:
          return "充值中";
        case 2:
          return "充值中";
        case 3:
          return "充值未通过";
        case 4:
          return "充值成功";
        default:
          return status;
      }
    };
    Vue.prototype.withdrawES = function(type) {
      switch (parseInt(type)) {
        case 1:
          return "充值";
        case 2:
          return "提现";
        default:
          return type;
      }
    };
    Vue.prototype.costTypeES = function(type) {
      switch (parseInt(type)) {
        case 1:
          return "视频播放";
        case 2:
          return "广播";
        default:
          return type;
      }
    };
    Vue.prototype.orderEs = function(status) {
      switch (parseInt(status)) {
        case 1:
          return "已下单";
        case 2:
          return "已完成";
        default:
          return status;
      }
    };
    Vue.prototype.couponEs = function(status) {
      switch (parseInt(status)) {
        case 1:
          return "已领取";
        case 2:
          return "已使用";
        case 3:
          return "已过期";
        default:
          return status;
      }
    };
    Vue.prototype.yearsEs = function(status) {
      switch (parseInt(status)) {
        case 1:
          return "1年";
        case 2:
          return "2年";
        case 3:
          return "3年";
        case 99:
          return "不限";
        default:
          return status;
      }
    };
    Vue.prototype.chargeTypeEs = function(status) {
      switch (parseInt(status)) {
        case 1:
          return "运营中心收费抽成";
        case 2:
          return "总部收费分成";
        default:
          return status;
      }
    };
    Vue.prototype.accountTypeEs = function(type) {
      switch (parseInt(type)) {
        case 1:
          return "预付费";
        case 2:
          return "月结算";
        default:
          return type;
      }
    };
    Vue.prototype.statusColor = function(status) {
      switch (parseInt(status)) {
        case 0:
          return "colorGreen";
        case 1:
          return "colorGreen";
        case 2:
          return "colorRed";
        case 3:
          return "colorRed";
        default:
          return "";
      }
    };
    Vue.prototype.statusColorSecond = function(status) {
      switch (parseInt(status)) {
        case 0:
          return "";
        case 1:
          return "";
        case 2:
          return "colorGreen";
        case 3:
          return "colorRed";
        case 4:
          return "colorRed";
        default:
          return "";
      }
    };
    Vue.prototype.applicColor = function(status) {
      switch (parseInt(status)) {
        case 6:
          return "colorRed";
        default:
          return "";
      }
    };
    Vue.prototype.videoType = function(type) {
      switch (parseInt(type)) {
        case 1:
          return "视频";
        case 2:
          return "图片";
        default:
          return type;
      }
    };
    Vue.prototype.applicStatus = function(status) {
      switch (parseInt(status)) {
        case 1:
          return "审核中";
        case 2:
          return "待发货";
        case 3:
          return "待收货";
        case 4:
          return "待绑定";
        case 5:
          return "已完成";
        case 6:
          return "未通过";
        default:
          return status;
      }
    };

    // 设备类型
    Vue.prototype.equipmentTypeEs = function(data, type) {
      let equipmentTypeName = "";
      data.forEach(element => {
        if (element.id === parseInt(type)) {
          equipmentTypeName = element.name;
        }
      });
      return equipmentTypeName;
    };
  }
};
